package myky.com.doctorapp.model;

import com.xiangyao.train.utils.RxScedulerHelper;

import java.util.HashMap;

import io.reactivex.Observable;
import myky.com.doctorapp.api.ApiManager;
import myky.com.doctorapp.base.BaseEntity;
import myky.com.doctorapp.contract.ChangePassWordContract;
import myky.com.doctorapp.entity.LogoutEntity;
import myky.com.doctorapp.entity.PreRequestEntuty;
import myky.com.doctorapp.utils.RequestBodyBuilder;

public class ChangePassWordModel implements ChangePassWordContract.Model {
    @Override
    public Observable<PreRequestEntuty> upPassWord() {
        return ApiManager.getApistore().pwdUpdate();
    }

    @Override
    public Observable<PreRequestEntuty> upPassWord(String oldPwd, String newPwd, String confirmPwd) {

        RequestBodyBuilder.Builder requestBodyBuilder=new RequestBodyBuilder.Builder();
        requestBodyBuilder.params("oldPwd",oldPwd).params("newPwd",newPwd).params("confirmNewPwd",confirmPwd);
        HashMap<String, String> map = requestBodyBuilder.getMap();

        return ApiManager.getApistore().pwdUpdateNow(map);
    }

    @Override
    public Observable<BaseEntity<LogoutEntity.PayLoadBean>> logout() {
        return ApiManager.getApistore().logoutApi().compose(RxScedulerHelper.INSTANCE.io_main());
    }
}
